package com.czxy.config;


import com.czxy.dao.DogDao;
import com.czxy.dao.impl.ADogDao;
import com.czxy.dao.impl.BDogDao;
import com.czxy.domain.Dog;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

@Configuration

@ComponentScan({"com.czxy"})
@PropertySource("classpath:db.properties")
@EnableAspectJAutoProxy // 告知 允许切面 编程


public class SpringConfig {














    @Bean
    public  static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){
        return new PropertySourcesPlaceholderConfigurer();
    }

    @Bean
    public  String showInfo(@Value("${jdbc.username}") String username,@Value("${jdbc.password}") String password){
       // System.out.println("username="+username +" password="+password);
        return "sssdds";
    }


    //通过工厂模式 指定dog对象初始化方法是init  销毁方法是destroy
    @Bean(initMethod = "init" ,destroyMethod = "destroy")
    public  Dog dog(){
        return new Dog();
    }





    @Bean(name = "aDogDao")
    public DogDao dogDao1(){
        return new ADogDao();

    }

    @Bean(name = "bDogDao")

    public  DogDao dogDao2(){
        return  new BDogDao();
    }

//    @Bean
//    public  String tet001(Dog dog){
//        System.out.println("test001 执行了");
//
//        dog.eat();
//        return "sdadadad";
//    }

































}
